package com.fz.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by webrx on 2017/6/26.
 */
@Controller
public class Holle {
    @RequestMapping("/index")
    public String index(){
        return "index";//index是前缀，后缀是jsp
    }


    @RequestMapping("/show.action") @ResponseBody
    public  void show(){
        System.out.println("show**************");
    }

    @RequestMapping("/user") @ResponseBody
    public  void user(HttpServletRequest req, HttpServletResponse res) throws IOException {
            res.setCharacterEncoding("utf-8");
            res.setContentType("text/html;charset=utf-8");
        PrintWriter out = res.getWriter();
        out.print("hello*****user");
    }

    @RequestMapping("/test")
    public ModelAndView test(){
        ModelAndView mv = new ModelAndView("test/dong");
            mv.addObject("name","王五");
            //mv.setViewName("");
        return mv;
    }

}
